package com.wc.alorithm_blue_bridge._动态规划.Q3965;

import java.util.*;
import java.io.*;

public class Main {
    static int maxN = 4000 + 7;
    static long[] f = new long[maxN];
    static FastReader sc = new FastReader();
    static int n;
    static int[] t = new int[maxN];
    static int[] c = new int[maxN];

    // t[i] 的时间获得c[i]的价值
    public static void main(String[] args) {
        n = sc.nextInt();
        int maxT = 0;
        for (int i = 1; i <= n; i++) {
            t[i] = sc.nextInt();
            c[i] = sc.nextInt();
            // 有一秒钟是拿你自己的，所以相当于t[i] + 1的时间只需要 c[i]的价值
            t[i]++;
            maxT = Math.max(maxT, t[i]);
        }
        int v = maxT + n;
        Arrays.fill(f, 1, v + 1, (long) 1e18);
        for (int i = 1; i <= n; i++) {
            for (int j = v; j >= t[i]; j--) {
                f[j] = Math.min(f[j], f[j - t[i]] + c[i]);
            }
        }
        long ans = (long) 1e18;
        // 每一件商品至少需要1秒钟的时间
        for (int i = n; i <= v; i++) {
            ans = Math.min(ans, f[i]);
        }
        System.out.println(ans);
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
}